package com.atkxp.utils;

import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.Map;

/**
 * @author user
 * @declaration
 * @create 2022/9/25-9:25
 */
public class WebUtils {
    public static <T> T copyParameterToBean(Map value, T bean){
        try {
            BeanUtils.populate(bean, value);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bean;
    }

    public static int parseInt(String id, int defaultValue){
        if(id != null && !"".equals(id)){
            return Integer.parseInt(id);
        }
        return defaultValue;
    }
}
